// nastavení
$.texyla("setDefaults", {
	emoticonPath: "%texyla_base%/emoticons/texy/%var%.gif",
	emoticons: {
		':-)': 'smile',
		':-(': 'sad',
		';-)': 'wink',
		':-D': 'biggrin',
		'8-O': 'eek',
		'8-)': 'cool',
		':-?': 'confused',
		':-x': 'mad',
		':-P': 'razz',
		':-|': 'neutral'		
	},
	emoticonWindowDimensions: [192, 170]
});

// tlačítko
$.texyla("addButton", "emoticon", function () {
	var _this = this;
	
	var emoticons = $('<div></div>');
	var emoticonsEl = $('<div class="emoticons"></div>').appendTo(emoticons);
	
	// projít smajly
	for (var i in this.options.emoticons) {
		function emClk(emoticon) {
			return function () {
				_this.texy.replace(emoticon);
				
				if (emoticons.find("input.close-after-insert").get(0).checked) {
					emoticons.dialog("close");
				}
			}
		};
		
		$(
			"<img src='" + this.options.emoticonPath.replace("%var%", this.options.emoticons[i]) + 
			"' title='" + i + "' alt='" + i + "' class='ui-default-state'>"
		)
			.click(emClk(i))
			.appendTo(emoticonsEl);
	}
	
	emoticons.append("<br><label><input type='checkbox' checked class='close-after-insert'> " + this.lng.windowCloseAfterInsert + "</label>");
	
	this.window({
		name: "emoticon",
		el: emoticons,
		title: this.lng.emoticonHeading
	});
});
